use Flap qw/-m -s -w/;

sub{
    my $c = shift;
    my $prt = $c->req->secure ? 'https' : 'http';
    $c->_global_->{static_root}{$prt} ||= do{
        my $proj = $c->project;
        my $cfg = $c->app_config;
        my $sr = $cfg->static_root->$prt;
        if(($cfg->{static_root_rev} || '') =~ m%^.+/svn\z%){
            foreach(map{ "$_/public/static" } $c->project_root, $c->app_root){
                my $rev = $proj->_global_->{static_root_rev}{$_} ||= do{
                    my $i = $proj->OS->qx('cd %path; %path info', $_, $cfg->static_root_rev);
                    $i =~ /\nLast Changed Rev: (\d+)/ ? $1 : $c->debug ? 1 : die $i;
                };
                $sr .= "_$rev";
            }
        }
        $sr;
    };
};
